<?php
include_once( "JO_01_configuration.php"	);
include_once( "JO_02_function.php"		);

$art=$_GET['art'];
$key='661';
$key=$_GET['tel'];
$JO_MySQL = new mysqli( $JO_DB_host, $JO_DB_user, $JO_DB_password, $JO_DB_database );
$JO_MySQL -> query( "SET NAMES 'UTF8'" );
					$query=" SELECT DISTINCT `note`,(select `artist`.`name` AS `name` from (`music` join `artist`) where ((`music`.`artist` = `artist`.`key`) and (`music`.`key` = `r`.`music`))) AS `artist`, (select group_concat(`r1`.`rbtcode` separator '<br>') AS 			`group_concat(``r1``.``rbtcode`` separator '<br>')` from `rbt` `r1` where ((`r1`.`telco` = '$key') and (`r1`.`music` = `r`.`music`) and (`r1`.`note` = `r`.`note`))) AS `rbtcode`,`telco` FROM `rbt` `r` WHERE `telco`='$key' AND (select `artist`.`key` AS `name` from (`music` join `artist`) where ((`music`.`artist` = `artist`.`key`) and (`music`.`key` = `r`.`music`)))=$art  ORDER BY `r`.`insert`,`r`.`note`
							;";
					$recordSet = JO_query( $query );
					$total=$recordSet->num_rows;
					if($total>=1 )
					{
					$page=1;
					$limit=10;
					if(($total%$limit)!=0) {$numpages=(int)($total/$limit)+1;}
            		else                {$numpages=$total/$limit;}
            		if(isset ($_REQUEST["Page"])){$page=$_REQUEST["Page"];}
					$vt=(($page-1)*$limit);
            		$query="SELECT DISTINCT `note`,(select `artist`.`name` AS `name` from (`music` join `artist`) where ((`music`.`artist` = `artist`.`key`) and (`music`.`key` = `r`.`music`))) AS `artist`, (select group_concat(`r1`.`rbtcode` separator '<br>') AS `group_concat(``r1``.``rbtcode`` separator '<br>')` from `rbt` `r1` where ((`r1`.`telco` = '$key') and (`r1`.`music` = `r`.`music`) and (`r1`.`note` = `r`.`note`))) AS `rbtcode`,`telco` FROM `rbt` `r` WHERE `telco`='$key' AND (select `artist`.`key` AS `name` from (`music` join `artist`) where ((`music`.`artist` = `artist`.`key`) and (`music`.`key` = `r`.`music`)))= $art  ORDER BY `r`.`insert`,`r`.`note` ASC limit $vt ,$limit";
					$recordSet = JO_query( $query );
					if( $recordSet -> num_rows ) while( $records = $recordSet -> fetch_array( ) ) {
					?>
<?php 

echo '<div style="width:15px;float:left;margin-right:30px;margin-top:4px;margin-bottom:4px"><img src="JO_80_image/my_music.png" width="30px;"/></div>';
echo '<div style="width:240px;float:left;margin-top:4px;margin-bottom:4px;">'.$records["note"].'</br>Artist : '.$records["artist"].'</div>';
echo '<div style="margin-top:4px !important ;width:100px;float:left;">'.$records['rbtcode'].'</div>';
 			$ct="";
            $arrrbt=array();
            $arrrbt=split("<br>", $records['rbtcode']);
            foreach ($arrrbt as $value){
			if($value!=""){
//echo '<div style="margin-top:4px !important ;width:30px ;float:left;" onClick="showobj("JO_60_WMPlayer.php?id='.trim($value,'  ').'&tel='.$telc.'","rbtplayer');"><img src="JO_80_image/JO_31_icon_stream_on.png" width="15px" /></div>';
		echo "<div style=\"margin-top:4px !important ;width:30px ;float:left;cursor:pointer\" onClick=\"showobj('JO_63_ajax_wmplayer.php?id=".trim($value," ")."&tel=".$key."','rbtplayer');\"><img src='JO_80_image/JO_31_icon_stream_on.png'width='15px' /></div>";
			}
			}
echo '<div class="cleared"></div>';
?>
<?php } ?>
<?php
echo "<div style='text-align:center;width:100%;font-weight:bold'>";

 					if($numpages>1){
                    if($page>2){
                    ?>

<div style="cursor:pointer;width:20px;float:left;margin-top:4px" onclick="tuyen_du_lieu('<?=$key ?>','1',<?=$art?>);">◀</div>
<?
                    }
                    if($page>1){
                    ?>
<div style="cursor:pointer;width:20px;float:left;margin-top:4px" onclick="tuyen_du_lieu('<?=$key ?>','<?=($page-1)?>',<?=$art?>);">◁</div>
<?
                    }
                    if($page-4>1) echo "<div style='cursor:pointer;width:15px;float:left;margin-top:4px'>...</div>";
                    ##################################
					for($i=$page-4;$i<=($page-1);$i++){
                        if($i>0){
                        ?>
<div style="cursor:pointer;width:20px;float:left;margin-top:4px" onclick="tuyen_du_lieu('<?=$key ?>','<?=$i?>',<?=$art?>);">
  <?=$i?>
</div>
<?
                        }
                    }
                    echo  "<div style='cursor:pointer;width:20px;float:left;margin-top:4px'><u>".$page."</u></div>";
                    for($i=$page+1;$i<=($page+4);$i++){
                        if($i<=$numpages){
						
                        ?>
<div style="cursor:pointer;width:20px;float:left;margin-top:4px" onclick="tuyen_du_lieu('<?=$key?>','<?=$i?>',<?=$art?>);">
  <?=$i?>
</div>

<?

                        }
                    }
					#######################################################
                    if($page+4<$numpages) echo "<div style='cursor:pointer;width:15px;float:left;margin-top:4px'>...</div>";
                    if($page<$numpages){
                    ?>
<div style="cursor:pointer;width:20px;float:left;margin-top:4px" onclick="tuyen_du_lieu('<?=$key?>',<?=($page+1)?>,<?=$art?>);">▷</div>
<?
                    }
                    if($page<($numpages-1)){
                    ?>
<div style="cursor:pointer;width:20px;float:left;margin-top:4px" onclick="tuyen_du_lieu('<?=$key ?>','<?=$numpages ?>',<?=$art?>);">▶</div>
<?
                    }

                }
			echo "</div>";
		?>
<?php }
		else
		{
		if($key=='VTL8x88')
			echo '<div style="text-align:center;width:100%;font-weight:bold">Tổng Đài Viettel ko có nhạc chờ của ca sĩ này</div>';
		
		if($key=='VMS8x88')
			echo '<div style="text-align:center;width:100%;font-weight:bold">Tổng Đài Mobiphone ko có nhạc chờ của ca sĩ này</div>';
	
		if($key=='GPC8x88')
			echo '<div style="text-align:center;width:100%;font-weight:bold">Tổng Đài VinaPhone ko có nhạc chờ của ca sĩ này</div>';
	
		if($key=='VNM8x88')
			echo '<div style="text-align:center;width:100%;font-weight:bold">Tổng Đài Vietnammobile ko có nhạc chờ của ca sĩ này</div>';
		
		if($key=='SFN8x88')
			echo '<div style="text-align:center;width:100%;font-weight:bold">Tổng Đài Sfone ko có nhạc chờ của ca sĩ này</div>';
	
		if($key=='Beeline')
			echo '<div style="text-align:center;width:100%;font-weight:bold">Tổng Đài Beeline ko có nhạc chờ của ca sĩ này</div>';
		}
		
		?>
